<?

class ZendLogAdapter implements ILog
{
    private $_componentInstance = null;
    
    public function __construct()
    {
        $this->_componentInstance = new Zend_Log();    
    }
    
    public function addPriority($priorityName, $level)
    {
        $this->_componentInstance->addPriority($priorityName, $level);
    }
    
    public function log($message, $priority)
    {
        $this->_componentInstance->log($message, $priority);
    }
    
    public function addFilter($filter)
    {
        $this->_componentInstance->addFilter($filter);
    }
    
    public function addWriter($writer)
    {
        $newWriter = null;
        
        if($writer instanceof LogWriterStream)
        {
            $newWriter = new Zend_Log_Writer_Stream($writer->getLogFile());
            if($writer->getFormatter() != null)
            {
                if($writer->getFormatter() instanceof LogFormatterSimple)
                {
                    $formatter = new Zend_Log_Formatter_Simple($writer->getFormatter()->get() . PHP_EOL);
                }else if($writer->getFormatter() instanceof LogFormatterXml)
                {
                    if($writer->getFormatter()->isModifed())
                    {
                        $formatter = new Zend_Log_Formatter_Xml($writer->getFormatter()->getRoot(), $writer->getFormatter()->getMaps());
                    }else
                    {
                        $formatter = new Zend_Log_Formatter_Xml();
                    }
                }
                
                $newWriter->setFormatter($formatter);
            }
        }        
        
        foreach($writer->getfilters() as $filter)
        {
            $newWriter->addFilter($filter);
        }
        
        $this->_componentInstance->addWriter($newWriter);
        
    }
}

?>